package com.fantasy.file;

import java.io.File;

public class ReadFilesName {
	
	int depth = 1;
	
	public static void main(String[] args) {
		ReadFilesName readFilesName = new ReadFilesName();
		int tempDepth = 0;
		readFilesName.readFolderName("d:\\" , tempDepth);
	}

	private void readFolderName(String folder, int tempDepth){
		File file = new File(folder);
		if (!file.isDirectory()) {
			System.out.println("请给一个文件夹目录");
			return ;
		}
		if (tempDepth == depth) {
			return ;
		}
		File[] files = file.listFiles();
		for (File file2 : files) {
			if(file2.isDirectory()){
				//readFileName(file2);
				readFolderName(file2.getAbsolutePath() , tempDepth + 1);
			}
			if(file2.isFile()){
				readFileName(file2);
			}
		}
	}
	
	private void readFileName(File file) {
		System.out.println(file.getAbsolutePath() + "大小" + file.length()/1024.0/1024.0);
	}
}
